-- Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
--
-- this file licensed under the Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-- PURPOSE.
-- See the Mulan PSL v2 for more details.
--
-- Author: auto generate
-- Create: 2025-10-19
-- Description: DO NOT EDIT; Code generated by "message.lua.mako"
local validate = require 'mc.validate'
local utils = require 'mc.utils'
local mdb = require 'mc.mdb'

local RemoteAccess = {}

---@class RemoteAccess.RemoteCallRsp
---@field Response string
local TRemoteCallRsp = {}
TRemoteCallRsp.__index = TRemoteCallRsp
TRemoteCallRsp.group = {}

local function TRemoteCallRsp_from_obj(obj)
    return setmetatable(obj, TRemoteCallRsp)
end

function TRemoteCallRsp.new(Response)
    return TRemoteCallRsp_from_obj({Response = Response})
end
---@param obj RemoteAccess.RemoteCallRsp
function TRemoteCallRsp:init_from_obj(obj)
    self.Response = obj.Response
end

function TRemoteCallRsp:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TRemoteCallRsp.group)
end

TRemoteCallRsp.from_obj = TRemoteCallRsp_from_obj

TRemoteCallRsp.proto_property = {'Response'}

TRemoteCallRsp.default = {''}

TRemoteCallRsp.struct = {{name = 'Response', is_array = false, struct = nil}}

function TRemoteCallRsp:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Response', self.Response, 'string', false, errs, need_convert)

    TRemoteCallRsp:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TRemoteCallRsp.proto_property, errs, need_convert)
    return self
end

function TRemoteCallRsp:unpack(_)
    return self.Response
end

RemoteAccess.RemoteCallRsp = TRemoteCallRsp

---@class RemoteAccess.GetRemotePropertiesReq
---@field Target string
---@field Object string
---@field Interface string
---@field Properties string[]
local TGetRemotePropertiesReq = {}
TGetRemotePropertiesReq.__index = TGetRemotePropertiesReq
TGetRemotePropertiesReq.group = {}

local function TGetRemotePropertiesReq_from_obj(obj)
    return setmetatable(obj, TGetRemotePropertiesReq)
end

function TGetRemotePropertiesReq.new(Target, Object, Interface, Properties)
    return TGetRemotePropertiesReq_from_obj({
        Target = Target,
        Object = Object,
        Interface = Interface,
        Properties = Properties
    })
end
---@param obj RemoteAccess.GetRemotePropertiesReq
function TGetRemotePropertiesReq:init_from_obj(obj)
    self.Target = obj.Target
    self.Object = obj.Object
    self.Interface = obj.Interface
    self.Properties = obj.Properties
end

function TGetRemotePropertiesReq:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TGetRemotePropertiesReq.group)
end

TGetRemotePropertiesReq.from_obj = TGetRemotePropertiesReq_from_obj

TGetRemotePropertiesReq.proto_property = {'Target', 'Object', 'Interface', 'Properties'}

TGetRemotePropertiesReq.default = {'', '', '', {}}

TGetRemotePropertiesReq.descriptions = {
    [=[The identifier of remote BMC, consist of 3 parts: protocol, address and channel. eg: CAN:5/0.]=],
    [=[The name of object which the remote properties belongs.]=],
    [=[The name of interface which the remote properties belongs.]=], [=[The name list of remote properties.]=]
}

TGetRemotePropertiesReq.struct = {
    {name = 'Target', is_array = false, struct = nil}, {name = 'Object', is_array = false, struct = nil},
    {name = 'Interface', is_array = false, struct = nil}, {name = 'Properties', is_array = true, struct = nil}
}

function TGetRemotePropertiesReq:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Target', self.Target, 'string', false, errs, need_convert)
    validate.Optional(prefix .. 'Object', self.Object, 'string', false, errs, need_convert)
    validate.Optional(prefix .. 'Interface', self.Interface, 'string', false, errs, need_convert)
    validate.OptionalArray(prefix .. 'Properties', self.Properties, 'string', false, errs, need_convert)

    TGetRemotePropertiesReq:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TGetRemotePropertiesReq.proto_property, errs, need_convert)
    return self
end

function TGetRemotePropertiesReq:unpack(_)
    return self.Target, self.Object, self.Interface, self.Properties
end

RemoteAccess.GetRemotePropertiesReq = TGetRemotePropertiesReq

---@class RemoteAccess.MethodArgs
---@field key string
---@field value string
local TMethodArgs = {}
TMethodArgs.__index = TMethodArgs
TMethodArgs.group = {}

local function TMethodArgs_from_obj(obj)
    return setmetatable(obj, TMethodArgs)
end

function TMethodArgs.new(dict)
    return TMethodArgs_from_obj(dict)
end

---@param obj RemoteAccess.MethodArgs
function TMethodArgs:init_from_obj(obj)
    self = obj
end

function TMethodArgs:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TMethodArgs.group)
end

TMethodArgs.from_obj = TMethodArgs_from_obj

TMethodArgs.proto_property = {}

TMethodArgs.default = {}

TMethodArgs.struct = {}

function TMethodArgs:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    for k, v in pairs(self) do

        validate.Optional(prefix .. 'key', k, 'string', false, errs, need_convert)

        validate.Optional(prefix .. 'value', v, 'string', false, errs, need_convert)

    end

    TMethodArgs:remove_error_props(errs, self)
    return self
end

function TMethodArgs:unpack(_)
    return self
end

RemoteAccess.MethodArgs = TMethodArgs

---@class RemoteAccess.RemoteCallReq
---@field Target string
---@field Object string
---@field Interface string
---@field Method string
---@field Signature string
---@field Args RemoteAccess.MethodArgs
local TRemoteCallReq = {}
TRemoteCallReq.__index = TRemoteCallReq
TRemoteCallReq.group = {}

local function TRemoteCallReq_from_obj(obj)
    return setmetatable(obj, TRemoteCallReq)
end

function TRemoteCallReq.new(Target, Object, Interface, Method, Signature, Args)
    return TRemoteCallReq_from_obj({
        Target = Target,
        Object = Object,
        Interface = Interface,
        Method = Method,
        Signature = Signature,
        Args = Args or [=[]=]
    })
end
---@param obj RemoteAccess.RemoteCallReq
function TRemoteCallReq:init_from_obj(obj)
    self.Target = obj.Target
    self.Object = obj.Object
    self.Interface = obj.Interface
    self.Method = obj.Method
    self.Signature = obj.Signature
    self.Args = obj.Args or [=[]=]
end

function TRemoteCallReq:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TRemoteCallReq.group)
end

TRemoteCallReq.from_obj = TRemoteCallReq_from_obj

TRemoteCallReq.proto_property = {'Target', 'Object', 'Interface', 'Method', 'Signature', 'Args'}

TRemoteCallReq.default = {'', '', '', '', '', RemoteAccess.MethodArgs.default}

TRemoteCallReq.descriptions = {
    [=[The identifier of remote BMC, consist of 3 parts: protocol, address and channel. eg: CAN:5/0.]=],
    [=[The name of object which the remote method belongs.]=],
    [=[The name of interface which the remote method belongs.]=], [=[The name of remote method.]=], nil,
    [=[The arguments of remote method.]=]
}

TRemoteCallReq.struct = {
    {name = 'Target', is_array = false, struct = nil}, {name = 'Object', is_array = false, struct = nil},
    {name = 'Interface', is_array = false, struct = nil}, {name = 'Method', is_array = false, struct = nil},
    {name = 'Signature', is_array = false, struct = nil},
    {name = 'Args', is_array = false, struct = RemoteAccess.MethodArgs.struct}
}

function TRemoteCallReq:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    RemoteAccess.MethodArgs.new(self.Args):validate(prefix, errs, need_convert)

    validate.Optional(prefix .. 'Target', self.Target, 'string', false, errs, need_convert)
    validate.Optional(prefix .. 'Object', self.Object, 'string', false, errs, need_convert)
    validate.Optional(prefix .. 'Interface', self.Interface, 'string', false, errs, need_convert)
    validate.Optional(prefix .. 'Method', self.Method, 'string', false, errs, need_convert)
    validate.Optional(prefix .. 'Signature', self.Signature, 'string', false, errs, need_convert)

    TRemoteCallReq:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TRemoteCallReq.proto_property, errs, need_convert)
    return self
end

function TRemoteCallReq:unpack(_)
    return self.Target, self.Object, self.Interface, self.Method, self.Signature, self.Args
end

RemoteAccess.RemoteCallReq = TRemoteCallReq

---@class RemoteAccess.RemoteProperties
---@field key string
---@field value string
local TRemoteProperties = {}
TRemoteProperties.__index = TRemoteProperties
TRemoteProperties.group = {}

local function TRemoteProperties_from_obj(obj)
    return setmetatable(obj, TRemoteProperties)
end

function TRemoteProperties.new(dict)
    return TRemoteProperties_from_obj(dict)
end

---@param obj RemoteAccess.RemoteProperties
function TRemoteProperties:init_from_obj(obj)
    self = obj
end

function TRemoteProperties:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TRemoteProperties.group)
end

TRemoteProperties.from_obj = TRemoteProperties_from_obj

TRemoteProperties.proto_property = {}

TRemoteProperties.default = {}

TRemoteProperties.struct = {}

function TRemoteProperties:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    for k, v in pairs(self) do

        validate.Optional(prefix .. 'key', k, 'string', false, errs, need_convert)

        validate.Optional(prefix .. 'value', v, 'string', false, errs, need_convert)

    end

    TRemoteProperties:remove_error_props(errs, self)
    return self
end

function TRemoteProperties:unpack(_)
    return self
end

RemoteAccess.RemoteProperties = TRemoteProperties

---@class RemoteAccess.GetRemotePropertiesRsp
---@field Values RemoteAccess.RemoteProperties
local TGetRemotePropertiesRsp = {}
TGetRemotePropertiesRsp.__index = TGetRemotePropertiesRsp
TGetRemotePropertiesRsp.group = {}

local function TGetRemotePropertiesRsp_from_obj(obj)
    return setmetatable(obj, TGetRemotePropertiesRsp)
end

function TGetRemotePropertiesRsp.new(Values)
    return TGetRemotePropertiesRsp_from_obj({Values = Values})
end
---@param obj RemoteAccess.GetRemotePropertiesRsp
function TGetRemotePropertiesRsp:init_from_obj(obj)
    self.Values = obj.Values
end

function TGetRemotePropertiesRsp:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TGetRemotePropertiesRsp.group)
end

TGetRemotePropertiesRsp.from_obj = TGetRemotePropertiesRsp_from_obj

TGetRemotePropertiesRsp.proto_property = {'Values'}

TGetRemotePropertiesRsp.default = {RemoteAccess.RemoteProperties.default}

TGetRemotePropertiesRsp.struct = {{name = 'Values', is_array = false, struct = RemoteAccess.RemoteProperties.struct}}

function TGetRemotePropertiesRsp:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    RemoteAccess.RemoteProperties.new(self.Values):validate(prefix, errs, need_convert)

    TGetRemotePropertiesRsp:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TGetRemotePropertiesRsp.proto_property, errs, need_convert)
    return self
end

function TGetRemotePropertiesRsp:unpack(_)
    return self.Values
end

RemoteAccess.GetRemotePropertiesRsp = TGetRemotePropertiesRsp

RemoteAccess.interface = mdb.register_interface('bmc.kepler.Debug.RemoteAccess', {}, {
    GetRemoteProperties = {
        'a{ss}sssas', 'a{ss}', TGetRemotePropertiesReq, TGetRemotePropertiesRsp,
        [=[Get properties of the object at remote BMC.]=]
    },
    RemoteCall = {
        'a{ss}sssssa{ss}', 's', TRemoteCallReq, TRemoteCallRsp, [=[Call method of the object at remote BMC.]=]
    }
}, {})

return RemoteAccess
